import java.applet.Applet;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Point;

import edu.uwm.cs552.HexCoordinate;
import edu.uwm.cs552.HexDirection;
import edu.uwm.cs552.HexEdge;


public class ViewHexEdge extends Applet {

	/**
	 * Keep Eclipse Happy
	 */
	private static final long serialVersionUID = 1L;
	
	private static final double SCALE = 40;
	
	private static HexCoordinate target = new HexCoordinate(3,2);
	private static HexEdge[] targets = {
		new HexEdge(target,HexDirection.EAST),
		new HexEdge(target,HexDirection.SOUTHWEST),
		new HexEdge(target,HexDirection.NORTHWEST)
	};
	private static Color[] colors = {
		Color.GREEN, Color.RED, Color.BLUE
	};

	@Override
	public void paint(Graphics g) {
		super.paint(g);
		for (int x=0; x < this.getWidth(); ++x) {
			for (int y=0; y < this.getHeight(); ++y) {
				HexCoordinate h = HexCoordinate.fromPoint(new Point(x,y), SCALE);
				Point remap = h.toPoint(SCALE);
				Color color = null;
				if (remap.x == x && remap.y == y) {
					color = Color.BLACK;
				} else {
					HexEdge e = HexEdge.fromPoint(new Point(x,y), SCALE);
					for (int i=0;i < targets.length; ++i) {
						if (e.equals(targets[i])) {
							color = colors[i];							
						}
					}
				}
				if (color == null && h.equals(target)) {
					color = Color.WHITE;
				}
				if (color != null) {
					g.setColor(color);
					g.fillRect(x, y, 1, 1);
				}
			}
		}
	}

}
